package org.ricks.ioc;

import org.ricks.ioc.bean.factory.AutowireCapableBeanFactory;
import org.ricks.ioc.bean.factory.AbstractBeanFactory;

/**
 * @author chenwei
 * @Title:
 * @Package
 * @Description:
 * @date 2020/6/2611:30
 */

public class ClassPathAppContext extends AbstractAppContext {

    public ClassPathAppContext(String packagePath){
        this(packagePath, new AutowireCapableBeanFactory());
    }

    public ClassPathAppContext(String packagePath, AbstractBeanFactory beanFactory){
        super(beanFactory,packagePath);
        refresh();
    }

//    public static void main(String[] args) {
//        Set<Class<?>> classesByPackageName = ClassUtil.getClasses("inutan");
//    }

    @Override
    protected void loadBeanDefinitions(AbstractBeanFactory beanFactory) {
        classes.forEach(clazz -> beanFactory.addBeanDefinition(clazz));
        beanFactory.initDao();
    }
}
